##################################################################################################################################
#
# Copyright (C) 2008-2013 Mind System Connection. Lda. Part of Daidze Software, created by Siqsuruq. All other rights reserved.
#
# Mind System Connection Webpage: www.msysc.org
# Daidze Software Page: www.daidze.com www.daidze.org
# E-mail: admin@msysc.org, siqsuruq@gmail.com
#
##################################################################################################################################

proc send_email {recipient subject body} {
    set token [mime::initialize -canonical text/plain -string $body]
    mime::setheader $token Subject $subject
	mime::setheader $token To $recipient
	mime::setheader $token From $::email

    smtp::sendmessage $token -recipients $recipient -ports $::email_port -servers $::email_server -username $::email -password $::email_password -originator $::email
    mime::finalize $token
}

proc register_user_email {} {
	set query "SELECT email, email_server, email_port, email_password FROM \"daidze_user\" WHERE name = \'$daidze_users::name\'"
	set result [lindex [$::db execute_query $query] 0]
	foreach val $result var [list email email_server email_port email_password] {
		set ::$var $val
	}
}

